import React from 'react'
import PropTypes from 'prop-types'
import { View, StyleSheet } from 'react-native'
import { ScaleT, ScaleS } from 'src/utils/ScreenUtil'
import JobListCell from './JobListCell'
import CustomButton from 'src/components/button/CustomButton'

import JobCell from 'src/components/job-cell/index'
export default class HomepageHeader extends React.PureComponent {
  static propTypes = {
    data: PropTypes.object,
    companyClick: PropTypes.func,
    positionList: PropTypes.any,
    jumpFn: PropTypes.func
  }

  cellClick = ({ id }) => {
    // const { jobClick, index } = this.props
    // jobClick(index)
    this.props.jumpFn({ id })
  }

  render () {
    const { positionList = {}, jumpFn, landmark } = this.props
    return (
      <View style={styles.view}>
        {
          (positionList || []).map((item, index) => {
            item.postWorkLocations = [
              {
                address: item.address,
                addressSimple: '',
                areaName: item.areaName
              }
            ]
            return (
              <CustomButton params={{ id: item.id }} key={index} onPress={this.cellClick}>
                <JobCell landmark={landmark} jumpFn={jumpFn} item={item} />
              </CustomButton>)
          })
        }
      </View>
    )
  }
}
const styles = StyleSheet.create({
  view: {
    minHeight: ScaleS(300),
    marginTop: ScaleS(10),
    overflow: 'hidden'
  }
})
